home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / prog / swin_0_1.zip / SOBJ2.INC < prev    next >
Text File  |  1993-01-19  |  3KB  |  153 lines

  1. Unit SObj2;
  2.  
  3. Interface
  4.  
  5. Uses Graph;
  6.  
  7. Const
  8.   BackGroundColor=0;
  9.  
  10. Type
  11.  
  12.   TsAttr=record
  13.     X,Y,W,H:Word;
  14.     Style:Word;
  15.     OldX,OldY,OldW,OldH:Word;
  16.     FrameThick:Byte;
  17.     Color,FrameColor,DisplayColor,TitleColor,MaxColor:Byte;
  18.   End;
  19.  
  20.   PsObject=^TsObject;
  21.   TsObject=object
  22.     HWindow:Word;
  23.     Constructor Init;
  24.     Destructor Done; virtual;
  25.     Procedure SetUpWindow; virtual;
  26.   End;
  27.  
  28.   PsLinkedList=^TsLinkedList;
  29.   TsLinkedList=record
  30.     Next,Previous:PsLinkedList;
  31.     Current:PsObject;
  32.   End;
  33.  
  34.   PsCollection=^TsCollection;
  35.   TsCollection=object(TsObject)
  36.     List:PsLinkedList;
  37.     NextHandle:Word;
  38.     Constructor Init;
  39.     Destructor Done; virtual;
  40.     Function Insert(sObject:PsObject):Word; virtual;
  41.     Function Delete(sHWindow:Word):Integer; virtual;
  42.     Function RetrieveFirst:PsObject; virtual;
  43.     Function RetrieveNext:PsObject; virtual;
  44.   End;
  45.  
  46. Implementation
  47.  
  48. (* TsObject Methods *)
  49.  
  50.   Constructor TsObject.Init;
  51.     Begin
  52.     End;
  53.  
  54.   Destructor TsObject.Done;
  55.     Begin
  56.     End;
  57.  
  58.   Procedure TsObject.SetUpWindow;
  59.     Begin
  60.     End;
  61.  
  62. (* TsCollection Methods *)
  63.  
  64.   Function TsCollection.RetrieveFirst:PsObject;
  65.     Begin
  66.       While List^.Previous<>nil Do
  67.         List:=List^.Previous;
  68.       RetrieveFirst:=List^.Current;
  69.     End;
  70.  
  71.   Function TsCollection.RetrieveNext:PsObject;
  72.     Begin
  73.       If List^.Next<>nil Then List:=List^.Next;
  74.       RetrieveNext:=List^.Current;
  75.     End;
  76.  
  77.   Constructor TsCollection.Init;
  78.     Begin
  79.       New(List);
  80.       List^.Next:=nil;
  81.       List^.Previous:=nil;
  82.       List^.Current:=nil;
  83.       NextHandle:=1;
  84.     End;
  85.  
  86.   Destructor TsCollection.Done;
  87.     Begin
  88.       While List^.Previous<>nil Do
  89.         Begin
  90.           List:=List^.Previous;
  91.           Dispose(List^.Next);
  92.         End;
  93.       Dispose(List);
  94.     End;
  95.  
  96.   Function TsCollection.Insert(sObject:PsObject):Word;
  97.     Var
  98.       Temp:PsLinkedList;
  99.  
  100.     Begin
  101.       While List^.Next<>nil Do
  102.         List:=List^.Next;
  103.       List^.Current:=sObject;
  104.       New(List^.Next);
  105.       Temp:=List;
  106.       List:=List^.Next;
  107.       List^.Previous:=Temp;
  108.       List^.Next:=Nil;
  109.       List^.Current:=Nil;
  110.       Insert:=NextHandle;
  111.       Inc(NextHandle);
  112.     End;
  113.  
  114.   Function TsCollection.Delete(sHWindow:Word):Integer;
  115.     Var
  116.       Temp:PsLinkedList;
  117.       t:Word;
  118.  
  119.     Begin
  120.       Delete:=sHWindow;
  121.       While List^.Previous<>nil Do
  122.         List:=List^.Previous;
  123.       For t:=1 To sHWindow-1 Do
  124.         Begin
  125.           If List^.Next<>nil Then
  126.             List:=List^.Next
  127.           Else
  128.             Begin
  129.               Delete:=-1;
  130.               Exit;
  131.             End;
  132.         End;
  133.       Temp:=List^.Next;
  134.       If List^.Next<>nil Then
  135.         List^.Next^.Previous:=List^.Previous;
  136.       If List^.Previous<>nil Then
  137.         List^.Previous^.Next:=Temp;
  138.       If List^.Next=nil Then
  139.         Temp:=List^.Previous
  140.       Else
  141.         Temp:=List^.Next;
  142.       Dispose(List);
  143.       Dec(NextHandle);
  144.       List:=Temp;
  145.       While List^.Next<>nil Do
  146.         Begin
  147.           List^.Current^.HWindow:=List^.Current^.HWindow-1;
  148.           List:=List^.Next;
  149.         End;
  150.     End;
  151.  
  152.  
  153. End.